// WORK_QUEUE_SIZE must be even for byte packing resons (8 byte alignment on structures)
#define WORK_QUEUE_SIZE 8
#ifdef __cplusplus
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include <iostream>
#include "EndianMath.h"
class NetvisSession;
class basePacket
{
protected: // data
UINT32 header;
UINT32 pad;
public:
enum PACKETtypes
{
VIS_PACKET_NULL,
VIS_PACKET_LOGIN, // Never change this id (it breaks graceful protocol negotiation)
VIS_PACKET_LOGIN_NAK, // Never change this id (it breaks graceful protocol negotiation)
VIS_PACKET_LOGIN_ACK, // Never change this id (it breaks graceful protocol negotiation)
VIS_PACKET_WANT_BSP_DATA, // Requests download of .bsp file image
VIS_PACKET_BSP_DATA_NAK, // Server not ready, try again later
VIS_PACKET_BSP_DATA, // .bsp image download
VIS_PACKET_BSP_NAME, // .bsp filename on server (for informational purposes on client)
VIS_PACKET_WANT_PRT_DATA, // Requests download of .prt file image
VIS_PACKET_PRT_DATA_NAK, // Server not ready, try again later
VIS_PACKET_PRT_DATA, // .prt image download
VIS_PACKET_WANT_MIGHTSEE_DATA, // Requests download of baseportalvis's calculated mightsee & nummightsee data
VIS_PACKET_MIGHTSEE_DATA_NAK, // Server is still crunching BasePortalVis, try again shortly
VIS_PACKET_MIGHTSEE_DATA, // One of (many) packets containing baseportalvis mightsee & nummightsee data
VIS_PACKET_LEAFTHREAD, // Tells server client BasePortalVis has completed and is awaiting work
VIS_PACKET_LEAFTHREAD_ACK, // Tells client LeafThread work is ready for request
VIS_PACKET_LEAFTHREAD_NAK, // Tells client server is not ready to parcel out LeafThread work yet
VIS_PACKET_WANT_FULL_SYNC, // Tells server that the client wants a sync
VIS_PACKET_DONE_PORTAL, // Gives server a completed work packet
VIS_PACKET_SYNC_PORTAL, // Internal packet for SYNC_PORTAL_CLUSTER
VIS_PACKET_SYNC_PORTAL_CLUSTER, // Multiple IS_SYNC_PORTAL packets embedded in a single packet, client to server sync up of work completed by all the other clients
VIS_PACKET_GOING_DOWN // Tells remote system connection is going to be terminated
{ // ATTN: This is a variable-length packet. Changing this structure requires fixing up the ::Send code, as well as the getPacketSizeByType method)
protected: // data
INT32 index[WORK_QUEUE_SIZE]; // >= 0 signifies this is a DONE sync, and to process this index
INT32 more_to_sync; // > 0 signifies there is more to sync, and a sync request should be fired off, 31 bits are available here if you really need them
INT32 server_total; // g_PortalArrayIndex of the server
INT32 subpacket_count; // number of subpackets
public:
CHAR data[MAX_PACKET_SIZE - sizeof(varPacket) - (sizeof(INT32) * (WORK_QUEUE_SIZE+2))]; // data must be the last structure (unless the use of offsetof is changed to work it out)
UINT32 compressed_size; // Total size of image in compressed bytes
UINT32 uncompressed_size; // Total size of image in uncompressed bytes
UINT32 fragment_size;
UINT32 offset;
public:
CHAR data[MAX_PACKET_SIZE - sizeof(varPacket) - (sizeof(UINT32) * 4)]; // data must be the last structure (unless the use of offsetof is changed to work it out)
UINT32 compressed_size; // Total size of image in compressed bytes
UINT32 uncompressed_size; // Total size of image in uncompressed bytes
UINT32 fragment_size;
UINT32 offset;
public:
CHAR data[MAX_PACKET_SIZE - sizeof(varPacket) - (sizeof(UINT32) * 4)]; // data must be the last structure (unless the use of offsetof is changed to work it out)